<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('商品订单列表')"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <p>所属商户：</p>
                            <select id="merchantId" class="form-control" name="merchantId">
                                <option value="">------全部------</option>
                                <option th:each="post:${mts}"
                                        th:value="${post.merchantId}"
                                        th:text="${post.merchantName}"></option>
                            </select>
                        </li>
                        <li>
                            <p>支付方式：</p>
                            <select name="orderWay" th:with="type=${@dict.getType('t_order_way')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            <p>订单状态：</p>
                            <select name="orderStatus" th:with="type=${@dict.getType('t_order_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>退款状态：</p>
                            <select name="orderRefundStatus" th:with="type=${@dict.getType('t_order_refund_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>用户姓名：</p>
                            <input type="text" name="userName"/>
                        </li>
                        <li>
                            <p>用户电话：</p>
                            <input type="text" name="userPhone"/>
                        </li>
                        <li>
                            <p>发货状态：</p>
                            <select name="deliverStatus" th:with="type=${@dict.getType('t_deliver_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <p>收货状态：</p>
                            <select name="receivingStatus" th:with="type=${@dict.getType('t_receiving_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>

                        <li>
                            <p>快递类型：</p>
                            <select name="expressType" th:with="type=${@dict.getType('')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <p>支付时间：</p>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginPayTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endPayTime]"/>
                        </li>
                        <li>
                            <p>用户id：</p>
                            <input type="text" name="userId"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset(null,'merchantId')"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--  <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="bussiness:commodityorder:add">
                  <i class="fa fa-plus"></i> 添加
              </a>
              <a class="btn btn-primary btn-edit disabled" onclick="$.operate.edit()"
                 shiro:hasPermission="bussiness:commodityorder:edit">
                  <i class="fa fa-edit"></i> 修改
              </a>
              <a class="btn btn-danger btn-del btn-del disabled" onclick="$.operate.removeAll()"
                 shiro:hasPermission="bussiness:commodityorder:remove">
                  <i class="fa fa-remove"></i> 删除
              </a>-->
            <a class="btn btn-warning" onclick="$.table.exportExcel()"
               shiro:hasPermission="bussiness:commodityorder:export">
                <i class="fa fa-download"></i> 导出
            </a>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('bussiness:commodityorder:edit')}]];
    var removeFlag = [[${@permission.hasPermi('bussiness:commodityorder:remove')}]];
    var orderWayDatas = [[${@dict.getType('t_order_way')}]];
    var orderStatusDatas = [[${@dict.getType('t_order_status')}]];
    var orderRefundStatusDatas = [[${@dict.getType('t_order_refund_status')}]];
    var deliverStatusDatas = [[${@dict.getType('t_deliver_status')}]];
    var receivingStatusDatas = [[${@dict.getType('t_receiving_status')}]];
    var expressTypeDatas = [[${@dict.getType('t_express_type')}]];
    var prefix = ctx + "bussiness/commodityorder";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "商品订单",
            sortName: "createTime",
            sortOrder: "desc",
            detailView: true,
            onExpandRow: function (index, row, $detail) {
                initChildTable(index, row, $detail);
            },
            columns: [
                {
                    field: 'merchantName',
                    title: '所属商户'
                },
                {
                    field: 'orderId',
                    title: '订单编号'
                },
                {
                    field: 'orderWay',
                    title: '支付方式',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(orderWayDatas, value);
                    }
                },
                {
                    field: 'orderMoney',
                    title: '订单金额',
                    visible: false
                },
                {
                    field: 'orderMoenyPay',
                    title: '支付金额'
                },
                {
                    field: 'orderMoenyDis',
                    title: '优惠金额',
                    visible: false
                },
                {
                    field: 'orderStatus',
                    title: '订单状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(orderStatusDatas, value);
                    }
                },
                {
                    field: 'orderRefundStatus',
                    title: '退款状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(orderRefundStatusDatas, value);
                    }
                },
                {
                    field: 'orderRemarks',
                    title: '订单备注'
                },
                {
                    field: 'userName',
                    title: '用户姓名'
                },
                {
                    field: 'userPhone',
                    title: '用户电话'
                },
                {
                    field: 'userAddress',
                    title: '用户地址'
                },
                {
                    field: 'deliverStatus',
                    title: '发货状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(deliverStatusDatas, value);
                    }
                },
                {
                    field: 'deliverTime',
                    title: '发货时间',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'receivingStatus',
                    title: '收货状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(receivingStatusDatas, value);
                    }
                },
                {
                    field: 'receivingTime',
                    title: '收货时间',
                    sortable: true,
                    visible: false
                },
                {
                    field: 'expressType',
                    title: '快递类型',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(expressTypeDatas, value);
                    }
                },
                {
                    field: 'expressNumber',
                    title: '快递单号',
                    visible: false
                },
                {
                    field: 'payTime',
                    title: '支付时间',
                    sortable: true
                },
                {
                    field: 'userId',
                    title: '用户编号'
                },
                {
                    field: 'createTime',
                    title: '创建时间',
                    sortable: true
                },
                {
                    field: 'updateTime',
                    title: '更新时间',
                    sortable: true
                },
                {
                    field: 'updateBy',
                    title: '操作人',
                    visible: false
                },
                {
                    field: 'updateRemarks',
                    title: '操作备注',
                    visible: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.orderId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        /*
                         actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.orderId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        */
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    initChildTable = function (index, row, $detail) {
        var childTable = $detail.html('<table style="table-layout:fixed"></table>').find('table');
        $(childTable).bootstrapTable({
            url: ctx + "bussiness/commodityorderdeputy" + "/list",
            method: 'post',
            sidePagination: "server",
            contentType: "application/x-www-form-urlencoded",
            queryParams: {
                "orderId": row.orderId
            },
            columns: [{
                field: 'deputyId',
                title: 'id',
                visible: false
            },
                {
                    field: 'commodityName',
                    title: '商品名称'
                },
                {
                    field: 'commodityCount',
                    title: '产品数量'

                },
                {
                    field: 'deputyMoney',
                    title: '产品金额'
                },
                {
                    field: 'deputyMoenyPay',
                    title: '支付金额'
                },
                {
                    field: 'deputyMoenyDis',
                    title: '优惠金额'
                }]
        });
    };
</script>
</body>
</html>